<template>
	<view v-if="pageShow">
		<image :src="require('@/static/image/system/yqhy.png')" mode="" style="width: 100%;height: 100vh;position: fixed;"></image>
		<view class="flexcenter">
			<view class="ewmpositin">
				<uqrcode ref="uqrcode" canvas-id="qrcode"  @click="ewmfn" v-bind:value="qrcodeurl" :options="{ margin: 10,foregroundImageSrc:'https://www.ecoodj.com/assets/img/avatar.png'}"
					size="200">
				</uqrcode>
			</view>
			<view class="sharepositin flexcenter">
				<!-- #ifdef MP-WEIXIN -->
				<button open-type="share" hover-class="none">
					<view class="flexcolunm">
						<image src="../static/image/system/weixin.png" style="width: 80rpx;height: 80rpx;" mode=""></image>
						<view class="margin_top1">微信</view>
					</view>
				</button>
				<!-- #endif -->
				<!-- #ifdef APP-PLUS -->
				<view class="flexcolunm" @click="wxshare">
					<image src="../static/image/system/weixin.png" style="width: 80rpx;height: 80rpx;" mode=""></image>
					<view class="margin_top1">微信</view>
				</view>
				<!-- <view class="flexcolunm margin_left6">
					<image src="../static/image/system/pyq.png" style="width: 80rpx;height: 80rpx;" mode=""></image>
					<view class="margin_top1">朋友圈</view>
				</view> -->
				<!-- #endif -->
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				qrcodeurl: "",
				pageShow:false,
			}
		},
		onLoad() {
			this.userinfomsg()
		},
		// #ifdef MP-WEIXIN
		onShareAppMessage() {
			let _this = this
			let pt_user_id = _this.userInfo.is_ptxs==1? uni.getStorageSync("user_id") : 0
			let cg_user_id = _this.userInfo.cgxs? uni.getStorageSync("user_id") : 0
			return {
				title: "动佳",
				path: "pages/homepage?rec_user_id=" + uni.getStorageSync("user_id")+"&pt_user_id="+pt_user_id+"&cg_user_id="+cg_user_id,
			}
		},
		// #endif
		methods: {
			userinfomsg() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
					this.getsystem()
				})
			},
			getsystem(){
				httpRequest.request('/api/index/getConfigInfo','GET',{}).then(res => {
					let pt_user_id = this.userInfo.is_ptxs==1? uni.getStorageSync("user_id") : 0
					let cg_user_id = this.userInfo.cgxs? uni.getStorageSync("user_id") : 0
					this.qrcodeurl = res.data.usershare_url + "?rec_user_id=" + uni.getStorageSync("user_id")+"&pt_user_id="+pt_user_id+"&cg_user_id="+cg_user_id
					console.log(this.qrcodeurl,"2883");
					this.pageShow=true
				})
			},
			// 二维码点击预览图片
			ewmfn() {
				this.$refs.uqrcode.toTempFilePath({
					success: res => {
						console.log(res);
						var i = [res.tempFilePath]; //获取当前页面的轮播图数据
						//uniapp预览轮播图
						uni.previewImage({
							current: 0, //预览图片的下标
							urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
						})
					}
				});
			},
			wxshare(){
				uni.share({
				    provider: 'weixin',
				    scene: "WXSceneSession",
				    type: 5,
				    // imageUrl: 'https://moveadd.yuntaiqi.com/uploads/20231209/4fa346dcff3b3ea21186e869334e4c51.jpg',
				    imageUrl: 'https://moveadd.yuntaiqi.com/uploads/20231209/73eb7695f5b6a32b51d8946b6fce1acc.png',
					
				    title: '动佳',
				    miniProgram: {
				        id: 'gh_bde51ae6eadc',
				        path: 'pages/index',
				        type: 2,
				        webUrl: 'http://uniapp.dcloud.io'
				    },
				    success: ret => {
				        console.log(JSON.stringify(ret));
				    },fail(err) {
				    	console.log(err);
				    }
				});

			},
		}
	}
</script>

<style lang="scss" scoped>
	.ewmpositin{
		position: fixed;
		top:40vh;
		
	}
	.sharepositin{
		position: fixed;
		bottom:10vh;
	}
	.margin_left6{
		margin-left: 200rpx;
	}
	.flexcolunm{
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
	}
</style>
